package com.wsd.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cif.domain.Customer;
import com.cif.service.CustomerService;
import com.wsd.common.Result;
import com.wsd.constant.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Classname UserListController
 * @Description TODO
 * @Date 2020/7/24 10:02
 * @Created by niuxiaojuan
 */
@RestController

@RequestMapping("/manage")
public class UserListController extends BaseController{

    @Reference(version = "1.0.0", url = "${dubbo.service.cifurl}")
    CustomerService customerService;

   @RequestMapping("/getUserList")
    public Result getUserList(@RequestParam("pagenum") int pagenum,@RequestParam("num") int num) {

       Result result=changeResult(customerService.getCustomerInfoList(pagenum,num));
       return result;
    }

   @RequestMapping("/getUserListByState")
    public Result getUserListByState(@RequestParam("state") String state,@RequestParam("pagenum") int pagenum,@RequestParam("num") int num) {

       Result result=changeResult(customerService.getCustomerInfoListByStatus(state,pagenum,num));
       return result;
    }

    @RequestMapping("/getUserById")
    public Result getUserById(@RequestParam("userId") String userId) {
        Result result=new Result();
        if (StringUtils.isEmpty(userId)) {
            result.setResultCode(ResultCode.PARAM_NOT_COMPLETE);
            return result;
        }
        result=changeResult(customerService.getCustomerById(userId));
        return result;
    }
}
